package com.xfcycle.zebrabikegp.util;

import android.app.Activity;

import java.util.Stack;

/**
 * 自定义窗体管理器，负责管理应用所有窗体
 * @author Wesley
 * jdk 1.8  Android 21
 * 2017年3月6日
 */
public class ActivitiesStackUtil {
	private static Stack<Activity> activities;
	
	private static ActivitiesStackUtil instance;
	
	private ActivitiesStackUtil(){
		activities = new Stack<Activity>();
	}

	public static ActivitiesStackUtil getInstance(){
		if(null == instance){
			instance = new ActivitiesStackUtil();
		}
		return instance;
	}
	
	public void push(Activity actvity){
		activities.add(actvity);
	}
	
	public Activity pop(){
		return activities.pop();
	}

	public int size(){
		return activities.size();
	}

	//关掉剩下的所有窗体，并退出应用
	public void exit(){
		while(!activities.isEmpty()){
			activities.pop().finish();
		}
		System.exit(0);
	}


}
